var express = require('express');
var router = express.Router();

router.get("/crossdomain.xml", function onCrossDomainHandler(req, res) {
    var xml = '<?xml version="1.0"?>\n<!DOCTYPE cross-domain-policy SYSTEM' +
        ' "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">\n<cross-domain-policy>\n';
    xml += '<allow-access-from domain="*" to-ports="*"/>\n';
    xml += '</cross-domain-policy>\n';

    req.setEncoding('utf8');
    res.writeHead(200, { 'Content-Type': 'text/xml' });
    res.end(xml);
})

router.get('/act/upload', function(req, res, next) {
    res.setHeader('Access-Control-Allow-Origin', '*');
    res.setHeader('X-Content-Type-Options', 'nosniff');
    console.log("打印" + req);
    res.json({
        code: 0,
        data: {
            video: {
                uid: 0,
                vid: 0,
                fileid: 0,
                filename: '',
                filemd5: '',
                limit: 1024 * 1024 * 1000,
            }
        }
    })
});

router.get('/act/userProfile', function(req, res, next) {
    res.setHeader('Access-Control-Allow-Origin', '*');
    res.setHeader('X-Content-Type-Options', 'nosniff');
    console.log("打印" + req);
    res.json({
        code: 0,
        data: {
            form: {
                uid: 0,
                vid: 1,
                fileid: 0,
                filename: '',
                filemd5: '',
                limit: 1024 * 1024 * 1000,
            }
        }
    })
});

router.get('/act/list', function(req, res, next) {
    res.setHeader('Access-Control-Allow-Origin', '*');
    res.setHeader('X-Content-Type-Options', 'nosniff');
    console.log("打印" + req);
    if (req.query.json = 1) {
        res.json({
            result: 0,
            data: [
                { "path": "周杰伦 - 告白气球.mp3", "size": 8624568, "name": "周杰伦 - 告白气球.mp3", "date": "2016-08-04" },
                { "path": "周杰伦 - 前世情人.mp3", "size": 3322808, "name": "周杰伦 - 前世情人.mp3", "date": "2016-08-04" },
                { "path": "周杰伦 - 前世情人(1).mp3", "size": 3210631, "name": "周杰伦 - 前世情人(1).mp3", "date": "2016-08-04" },
                { "path": "周杰伦 - 说走就走 (1).flac", "size": 57877274, "name": "周杰伦 - 说走就走 (1).flac", "date": "2016-08-04" },
                { "path": "周杰伦 - 说走就走.flac", "size": 57877274, "name": "周杰伦 - 说走就走.flac", "date": "2016-08-04" },
                { "path": "周杰伦 - 英雄.flac", "size": 26028721, "name": "周杰伦 - 英雄.flac", "date": "2016-08-04" },
                { "path": "走钢索的人.mp3", "size": 2886531, "name": "走钢索的人.mp3", "date": "2016-08-04" }
            ]
        })
    } else {
        res.jsonp({
            result: 0,
            data: [
                { "path": "周杰伦 - 告白气球.mp3", "size": 8624568, "name": "周杰伦 - 告白气球.mp3", "date": "2016-08-04" },
                { "path": "周杰伦 - 前世情人.mp3", "size": 3322808, "name": "周杰伦 - 前世情人.mp3", "date": "2016-08-04" },
                { "path": "周杰伦 - 前世情人(1).mp3", "size": 3210631, "name": "周杰伦 - 前世情人(1).mp3", "date": "2016-08-04" },
                { "path": "周杰伦 - 说走就走 (1).flac", "size": 57877274, "name": "周杰伦 - 说走就走 (1).flac", "date": "2016-08-04" },
                { "path": "周杰伦 - 说走就走.flac", "size": 57877274, "name": "周杰伦 - 说走就走.flac", "date": "2016-08-04" },
                { "path": "周杰伦 - 英雄.flac", "size": 26028721, "name": "周杰伦 - 英雄.flac", "date": "2016-08-04" },
                { "path": "走钢索的人.mp3", "size": 2886531, "name": "走钢索的人.mp3", "date": "2016-08-04" }
            ]
        })
    }

});

router.post('/post/list', function(req, res, next) {
    res.setHeader('Access-Control-Allow-Origin', '*');
    res.setHeader('X-Content-Type-Options', 'nosniff');
    console.log(req.body);
    res.json({
        code: 0,
        data: [
            { "path": "周杰伦 - 告白气球.mp3", "size": 8624568, "name": "周杰伦 - 告白气球.mp3", "date": "2016-08-04" },
            { "path": "周杰伦 - 前世情人.mp3", "size": 3322808, "name": "周杰伦 - 前世情人.mp3", "date": "2016-08-04" },
            { "path": "周杰伦 - 前世情人(1).mp3", "size": 3210631, "name": "周杰伦 - 前世情人(1).mp3", "date": "2016-08-04" },
            { "path": "周杰伦 - 说走就走 (1).flac", "size": 57877274, "name": "周杰伦 - 说走就走 (1).flac", "date": "2016-08-04" },
            { "path": "周杰伦 - 说走就走.flac", "size": 57877274, "name": "周杰伦 - 说走就走.flac", "date": "2016-08-04" },
            { "path": "周杰伦 - 英雄.flac", "size": 26028721, "name": "周杰伦 - 英雄.flac", "date": "2016-08-04" },
            { "path": "走钢索的人.mp3", "size": 2886531, "name": "走钢索的人.mp3", "date": "2016-08-04" }
        ]
    })
});

router.get('/act/preorderlotto/lottery_profile', function(req, res, next) {
    res.setHeader('Access-Control-Allow-Origin', '*');
    res.jsonp({
        code: 0,
        data: {
            lottery_item_list: [{
                    describe_pic: "http://7oxgb1.com1.z0.glb.clouddn.com/act/lotto_295808/2000.png",
                    describe_text: "",
                    id: 49
                },
                {
                    describe_pic: "http://7oxgb1.com1.z0.glb.clouddn.com/act/lotto_295808/medal.png",
                    describe_text: "TT勋章",
                    id: 50
                },
                {
                    describe_pic: "http://7oxgb1.com1.z0.glb.clouddn.com/act/lotto_295808/recharge.png",
                    describe_text: "充值卡",
                    id: 52
                },
                {
                    describe_pic: "http://7oxgb1.com1.z0.glb.clouddn.com/act/lotto_295808/ticket.png",
                    describe_text: "代金券",
                    id: 51
                },
                {
                    describe_pic: "http://7oxgb1.com1.z0.glb.clouddn.com/act/lotto_295808/giftpkg.png",
                    describe_text: "预约礼包",
                    id: 48
                }
            ],
            lottery_record_list: [{
                    describe_text: "588礼包",
                    id: 2,
                    ttid: "29084792"
                },
                {
                    describe_text: "充值卡",
                    id: 9,
                    ttid: "29084792"
                },
                {
                    describe_text: "288礼包",
                    id: 11,
                    ttid: "29084792"
                },
                {
                    describe_text: "288礼包",
                    id: 14,
                    ttid: "29084792"
                }
            ],
            mine_record_list: [{
                    describe_text: "588礼包",
                    id: 2,
                    ttid: "29084792"
                },
                // {
                //     describe_text: "充值卡",
                //     id: 9,
                //     ttid: "29084792"
                // },
                //  {
                //     describe_text: "288礼包",
                //     id: 11,
                //     ttid: "29084792"
                // }
            ],
            profile: {
                banner: "http://7oxgb1.com1.z0.glb.clouddn.com/act/lotto_295808/banner.jpg",
                bg_color: "#1e1b2e",
                circle_id: 0,
                follow_btn: "http://7oxgb1.com1.z0.glb.clouddn.com/act/lotto_295808/btn_follow.png",
                is_follow: 0,
                is_share: 0,
                lottery_counts: 12121,
                rules_pic: "http://7oxgb1.com1.z0.glb.clouddn.com/act/lotto_295808/rules.png"
            }
        },
        msg: "ok"
    })

})

router.get('/act/preorderlotto/lottery', function(req, res, next) {
    res.setHeader('Access-Control-Allow-Origin', '*');
    res.setHeader('X-Content-Type-Options', 'nosniff');
    // res.send('你妹的');
    res.jsonp({
        code: 0,
        data: {
            lottery_item_list: [{
                    describe_pic: "http://7oxgb1.com1.z0.glb.clouddn.com/act/lotto_295673/588.png",
                    describe_text: "588礼包",
                    id: 2
                },
                {
                    describe_pic: "http://7oxgb1.com1.z0.glb.clouddn.com/act/lotto_295673/2000.png",
                    describe_text: "2000红钻",
                    id: 4
                },
                {
                    describe_pic: "http://7oxgb1.com1.z0.glb.clouddn.com/act/lotto_295673/medal.png",
                    describe_text: "TT勋章",
                    id: 5
                },
                {
                    describe_pic: "http://7oxgb1.com1.z0.glb.clouddn.com/act/lotto_295673/888.png",
                    describe_text: "888礼包",
                    id: 3
                },
                {
                    describe_pic: "http://7oxgb1.com1.z0.glb.clouddn.com/act/lotto_295673/recharge.png",
                    describe_text: "充值卡",
                    id: 6
                },
                {
                    describe_pic: "http://7oxgb1.com1.z0.glb.clouddn.com/act/lotto_295673/288.png",
                    describe_text: "288礼包",
                    id: 11
                }
            ],
            lottery_record_list: [{
                    describe_text: "588礼包",
                    id: 2,
                    ttid: "29084792"
                },
                {
                    describe_text: "充值卡",
                    id: 9,
                    ttid: "29084792"
                },
                {
                    describe_text: "288礼包",
                    id: 11,
                    ttid: "29084792"
                }
            ],
            result_item_list: [{
                    describe_pic: "http://7oxgb1.com1.z0.glb.clouddn.com/act/lotto_295808/medal.png",
                    describe_text: "TT勋章",
                    id: 50
                },
                {
                    describe_pic: "http://7oxgb1.com1.z0.glb.clouddn.com/act/lotto_295808/2000.png",
                    describe_text: "2000红钻",
                    id: 53
                },
                {
                    describe_pic: "http://7oxgb1.com1.z0.glb.clouddn.com/act/lotto_295808/ticket.png",
                    describe_text: "代金券",
                    id: 51
                },
                {
                    describe_pic: "http://7oxgb1.com1.z0.glb.clouddn.com/act/lotto_295808/recharge.png",
                    describe_text: "充值卡",
                    id: 52
                },
                {
                    describe_pic: "http://7oxgb1.com1.z0.glb.clouddn.com/act/lotto_295808/giftpkg.png",
                    describe_text: "预约礼包",
                    id: 48
                }
            ],
            mine_record_list: [{
                    describe_text: "588礼包",
                    id: 2,
                    ttid: "29084792"
                },
                // {
                //     describe_text: "充值卡",
                //     id: 9,
                //     ttid: "29084792"
                // },
                //  {
                //     describe_text: "288礼包",
                //     id: 11,
                //     ttid: "29084792"
                // }
            ],
            profile: {
                banner: "http://7oxgb1.com1.z0.glb.clouddn.com/act/lotto_295673/banner2.jpg",
                bg_color: "#060219",
                circle_id: 756,
                follow_btn: "http://7oxgb1.com1.z0.glb.clouddn.com/act/lotto_295673/btn_follow.png",
                game_icon: "http://7oxgb1.com2.z0.glb.qiniucdn.com/o_1amvvep5aqtadrkj7pi6f57517.png?imageView2/1/w/120/h/120&imageView2/1/w/144/h/144/format/jpg/q/90",
                game_name: "雪鹰领主",
                is_follow: 1,
                is_share: 0,
                lottery_counts: 11212,
                rules_pic: "http://7oxgb1.com1.z0.glb.clouddn.com/act/lotto_295673/rules.png"
            }
        },
        msg: "ok"
    })
})


/* GET users listing. */
router.get('/gshare/init', function(req, res, next) {
    // res.setHeader('Access-Control-Allow-Origin', '*');
    //res.send('../ajax.html');
    res.jsonp({
        code: 0,
        data: {
            user: {
                uid: 0,
                account: 0,
                head: 0,
                name: 0,
                guild_id: 0,
                guild_title: 0,
                level: 0,
                guild_identity: 0,
                guild_level: 0,
                guild_slogan: 0,
                guild_member: 0,
                invitation_code: ''
            }
        },
        msg: "OK"
    });
});


module.exports = router;